package com.xzz.string;


/**
 * @author: hhz
 * @create: 2022-01-07 10:41
 * 1614. 括号的最大嵌套深度
 *
 **/
public class MaxDepth {
    public static void main(String[] args) {
        System.out.println(maxDepth("1+(2*3)/(2-1)"));
        System.out.println(maxDepth("(1+(2*3)+((8)/4))+1"));
        System.out.println(maxDepth("(1)+((2))+(((3)))"));
        System.out.println(maxDepth("1"));
    }
    public static int maxDepth(String s) {
        int res = 0;
        int temp = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if(c=='('){
                temp++;
            }else if(c==')'){
                res = Math.max(res,temp);
                temp--;
            }
        }
        return res;
    }
}
